package com.household.domain.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * Created By wanzhen
 * 2023. 2023/3/25. 10:42
 */

@Getter
@AllArgsConstructor
public enum RoleEnum {
    ADMIN(1,"ROLE_ADMIN","系统管理员"),
    USER(2,"ROLE_USER","普通用户"),
    COMPANY(3,"ROLE_COMPANY","家政公司"),
    DIS_FORMAL(-1,"DIS_FORMAL","非正式用户");

//    数据库保存值
//    角色类型
    @EnumValue
    private Integer type;

    private String name;
//    角色中文名
    private String cName;

    public static RoleEnum getByType(int type) {
        return Arrays.stream(values()).filter(e -> e.getType() == type).findFirst().orElse(null);
    }
}
